//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    formType:{},
    userInfo: {},
    hasUserInfo:false,
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    time:{}
  },
  //事件处理函
  onLoad: function () {
    var _this = this;    
    wx.getSetting({
      success:res=>{
        if(!res.authSetting['scope.userInfo']){
          _this.setData({
            hasUserInfo:true
          })
        }
      }
    })
  },
  china:function(e){
    var _this = this;
    _this.setData({
      formType: 0
    })
    app.globalData.formType = _this.data.formType,
      wx.navigateTo({
        url: '../list/list',
      })
  },

  abroad:function (e) {
    var _this = this;
    _this.setData({
      formType: 1
    })
    app.globalData.formType = _this.data.formType,
    wx.navigateTo({
      url: '../list/list',
    })
  },

  getUserInfo_zh:function(e){
    var _this = this
    if (e.detail.userInfo){
    
      app.setUserinfo();
      _this.setData({
        hasUserInfo:false
      })
    }else{
      wx.showToast({
        title: "为了您更好的体验,请先同意授权",
        icon: 'none',
        duration: 2000
      }); 
    }
  },
  onShareAppMessage: function () {
        
  },
})
